package cn.com.tianpeidong.restaurantadmin.project.admin.order.rest;

import cn.com.tianpeidong.restaurantadmin.common.util.page.PageWrapper;
import cn.com.tianpeidong.restaurantadmin.project.admin.order.entity.Order;
import cn.com.tianpeidong.restaurantadmin.project.admin.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author tianpeidong
 * @version 创建时间: 19-6-2 下午2:33
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @GetMapping
    public ResponseEntity list(@RequestParam(value = "pagi") boolean isPagi,
                               @RequestParam(value = "per_page", required = false) Integer pageSize,
                               @RequestParam(value = "page", required = false) Integer page) {
        PageWrapper pageWrapper = new PageWrapper(pageSize, page);
        List<Order> dishesList = orderService.listOrder(new Order());
        return ResponseEntity.ok(pageWrapper.getResult(dishesList));
    }
}
